<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>URL解析</title>
<script type="text/javascript" src="urlStr.js"></script>
<style>
body{
	font-size:14px;
	font-family:Arial, Helvetica, sans-serif;
}
</style>
</head>

<body>
<script>
var url = 'http://user:password@www.codebit.cn:9901/pub/article.php?offset=10&perpage=10#fragment';

var p = new Poly9.URLParser(location);

document.write("<strong>示例URL: </strong> " + url + "<br /><br />");
document.write("解析结果如下： <br /><br />");
document.write("<strong>Protocol(协议名): </strong> " + p.getProtocol() + "<br />");
document.write("<strong>Username(用户名): </strong> " + p.getUsername() + "<br />");
document.write("<strong>Password(密码): </strong> " + p.getPassword() + "<br />");
document.write("<strong>Host(主机名): </strong> " + p.getHost() + "<br />");
document.write("<strong>Port(端口): </strong> " + p.getPort() + "<br />");
document.write("<strong>Pathname(路径): </strong> " + p.getPathname() + "<br />");
document.write("<strong>Query String(参数字符): </strong> " + p.getQuerystring() + "<br />");
document.write("<strong>Fragment(片段): </strong> " + p.getFragment() + "<br />");

document.write(location);

if(p.getQuerystring()=="pageType=1&sub=01"){
	alert("Type1")
}
if(p.getQuerystring()=="pageType=1&sub=02"){
	alert("Type2")
}
else{
	alert("none")
}
</script>
</body>
</html>
